/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.evote.monitoreo.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Mendoza
 */
@Entity
@Table(name = "opcion", catalog = "evote", schema = "")
@NamedQueries({
    @NamedQuery(name = "Opcion.findAll", query = "SELECT o FROM Opcion o"),
    @NamedQuery(name = "Opcion.findByIdOpcion", query = "SELECT o FROM Opcion o WHERE o.idOpcion = :idOpcion"),
    @NamedQuery(name = "Opcion.findByOrden", query = "SELECT o FROM Opcion o WHERE o.orden = :orden"),
    @NamedQuery(name = "Opcion.findByFechaCreacion", query = "SELECT o FROM Opcion o WHERE o.fechaCreacion = :fechaCreacion")})
public class Opcion implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "idOpcion", nullable = false)
    private Integer idOpcion;
    @Column(name = "orden")
    private Integer orden;
    @Column(name = "fechaCreacion")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fechaCreacion;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "opcionidOpcion")
    private List<Escrutinio> escrutinioList;
    @JoinColumn(name = "Cedula_idCedula", referencedColumnName = "idCedula", nullable = false)
    @ManyToOne(optional = false)
    private Cedula cedulaidCedula;
    @JoinColumn(name = "Candidato_PartidoPolitico_idCandidato_PartidoPolitico", referencedColumnName = "idCandidato_PartidoPolitico", nullable = false)
    @ManyToOne(optional = false)
    private CandidatoPartidopolitico candidatoPartidoPoliticoidCandidatoPartidoPolitico;

    public Opcion() {
    }

    public Opcion(Integer idOpcion) {
        this.idOpcion = idOpcion;
    }

    public Integer getIdOpcion() {
        return idOpcion;
    }

    public void setIdOpcion(Integer idOpcion) {
        this.idOpcion = idOpcion;
    }

    public Integer getOrden() {
        return orden;
    }

    public void setOrden(Integer orden) {
        this.orden = orden;
    }

    public Date getFechaCreacion() {
        return fechaCreacion;
    }

    public void setFechaCreacion(Date fechaCreacion) {
        this.fechaCreacion = fechaCreacion;
    }

    public List<Escrutinio> getEscrutinioList() {
        return escrutinioList;
    }

    public void setEscrutinioList(List<Escrutinio> escrutinioList) {
        this.escrutinioList = escrutinioList;
    }

    public Cedula getCedulaidCedula() {
        return cedulaidCedula;
    }

    public void setCedulaidCedula(Cedula cedulaidCedula) {
        this.cedulaidCedula = cedulaidCedula;
    }

    public CandidatoPartidopolitico getCandidatoPartidoPoliticoidCandidatoPartidoPolitico() {
        return candidatoPartidoPoliticoidCandidatoPartidoPolitico;
    }

    public void setCandidatoPartidoPoliticoidCandidatoPartidoPolitico(CandidatoPartidopolitico candidatoPartidoPoliticoidCandidatoPartidoPolitico) {
        this.candidatoPartidoPoliticoidCandidatoPartidoPolitico = candidatoPartidoPoliticoidCandidatoPartidoPolitico;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idOpcion != null ? idOpcion.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Opcion)) {
            return false;
        }
        Opcion other = (Opcion) object;
        if ((this.idOpcion == null && other.idOpcion != null) || (this.idOpcion != null && !this.idOpcion.equals(other.idOpcion))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.evote.monitoreo.entity.Opcion[idOpcion=" + idOpcion + "]";
    }

}
